package com.nuoniu.sibanyun.mapper.production;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nuoniu.sibanyun.entity.bo.VProductionWorkDetailBo;
import com.nuoniu.sibanyun.entity.production.VProductionWorkDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 生产加工单明细 Mapper 接口
 * </p>
 *
 * @author 小啊刚
 * @since 2021-03-13
 */
@Component
@Mapper
public interface VProductionWorkDetailMapper extends BaseMapper<VProductionWorkDetail> {

    @Select("SELECT id FROM ma_written_instruction_detail WHERE company_id = #{companyId} AND account_id = #{accountId}  AND order_id = #{mainId}")
    List<Integer> getDetailByMainId(Integer companyId,Integer accountId, Integer mainId);


    VProductionWorkDetailBo getVProductionWorkDetailBo(Integer companyId,Integer accountId, Integer id);

    List<VProductionWorkDetail> listNotDispatchedDetail(Integer companyId,Integer accountId,Integer mainId);

    List<VProductionWorkDetail> listNotDispatchedDetail2(Integer companyId,Integer accountId,Integer mainId);

    boolean updateCumDispatchQuantity(Integer companyId,Integer accountId,Integer id, BigDecimal offset);

    /**
     * 查询bom使用数量
     * @author 小啊刚
     * @date 2021-07-21
     */
    @Select("select count(1) from ma_written_instruction_detail where bom_id=#{bomId}")
    Integer getCountByBom(Long bomId);
}
